********************************************************************************
* Rainer Kotschy, Patricio Suarez Urtaza, and Uwe Sunde
* The Demographic Dividend Is More Than an Education Dividend
* Replication Material


cd
clear all
set more off
use "kss_data.dta"
xtset id year, delta(5)


*Install necessary software packages
ssc install reghdfe
ssc install ftools
ssc install moremata
ssc install estout
ssc install coefplot


********************************************************************************
* Table 1: Population Age Structure, Education, and the Demographic Dividend


* Column 1: Full sample
reghdfe growth D.lnrkpc D.lnshpop1564 pprimeduc1564 L.lnshpop1564 L.lnrgdppc c.pprimeduc1564#cL.lnshpop1564 c.pprimeduc1564#cL.lnrgdppc, a(id year) cl(id)
eststo col1

* Column 2: OECD countries
reghdfe growth D.lnrkpc D.lnshpop1564 pprimeduc1564 L.lnshpop1564 L.lnrgdppc c.pprimeduc1564#cL.lnshpop1564 c.pprimeduc1564#cL.lnrgdppc if oecd == 1, a(id year) cl(id)
eststo col2

* Column 3: Non-OECD countries
reghdfe growth D.lnrkpc D.lnshpop1564 pprimeduc1564 L.lnshpop1564 L.lnrgdppc c.pprimeduc1564#cL.lnshpop1564 c.pprimeduc1564#cL.lnrgdppc if oecd == 0, a(id year) cl(id)
eststo col3
	
* Display results
esttab col*, b(%4.2f) se(%4.2f) star(* .1 ** .05 *** .01) obslast scalars(N_clust) sfmt(a2) r2(%3.2f) ar2(%3.2f) drop(_cons) nonotes compress


********************************************************************************
* Figure 1: Population Age Structure, Education, and the Demographic Dividend


* Figure 1a: Effect of Age Structure

* Compute marginal effect for full sample
qui reghdfe growth D.lnrkpc D.lnshpop1564 pprimeduc1564 L.lnshpop1564 L.lnrgdppc c.pprimeduc1564#cL.lnshpop1564 c.pprimeduc1564#cL.lnrgdppc, a(id year) cl(id)
margins, dydx(L.lnshpop1564) at(pprimeduc1564 = (.09(.1).89)) post
eststo wap1

* Compute marginal effect for OECD countries
qui reghdfe growth D.lnrkpc D.lnshpop1564 pprimeduc1564 L.lnshpop1564 L.lnrgdppc c.pprimeduc1564#cL.lnshpop1564 c.pprimeduc1564#cL.lnrgdppc if oecd == 1, a(id year) cl(id)
margins, dydx(L.lnshpop1564) at(pprimeduc1564 = (.1(.1).9)) post
eststo wap2

* Compute marginal effect for non-OECD countries
qui reghdfe growth D.lnrkpc D.lnshpop1564 pprimeduc1564 L.lnshpop1564 L.lnrgdppc c.pprimeduc1564#cL.lnshpop1564 c.pprimeduc1564#cL.lnrgdppc if oecd == 0, a(id year) cl(id)
margins, dydx(L.lnshpop1564) at(pprimeduc1564 = (.11(.1).91)) post
eststo wap3
	
* Plot coefficients
#delimit;
coefplot (wap1, msym(c)) (wap2, msym(s)) (wap3, msym(d)),
	at ciopts(recast(rspike))
	ytitle("Marginal effect of lagged working-age share on growth", size(medsmall))
	ylab(-2(1)3, nogrid angle(0) labsize(medsmall) format(%4.0f))
	ysca(titlegap(2))
	yline(0, lcolor(ltbluishgray))
	xtitle("Share with post-primary education in working-age population", size(medsmall))
	xlab(.1(.1).9, nogrid angle(0) labsize(medsmall) format(%4.1f))
	xsca(titlegap(2))
	legend(rows(1) cols(3) ring(0) position(10) label(2 "Full Sample") label(4 "OECD") label(6 "Non OECD"))
	graphregion(color(white)) bgcolor(white)
;
#delimit cr


* Figure 1b: Effect of Education

* Compute marginal effect for full sample
qui reghdfe growth D.lnrkpc D.lnshpop1564 pprimeduc1564 L.lnshpop1564 L.lnrgdppc c.pprimeduc1564#cL.lnshpop1564 c.pprimeduc1564#cL.lnrgdppc, a(id year) cl(id)
margins, dydx(pprimeduc1564) at(L.lnshpop1564 = (-.91(.1)-.11)) post
eststo educ1

* Compute marginal effect for OECD countries
qui reghdfe growth D.lnrkpc D.lnshpop1564 pprimeduc1564 L.lnshpop1564 L.lnrgdppc c.pprimeduc1564#cL.lnshpop1564 c.pprimeduc1564#cL.lnrgdppc if oecd == 1, a(id year) cl(id)
margins, dydx(pprimeduc1564) at(L.lnshpop1564 = (-.9(.1)-.1)) post
eststo educ2

* Compute marginal effect for non-OECD countries
qui reghdfe growth D.lnrkpc D.lnshpop1564 pprimeduc1564 L.lnshpop1564 L.lnrgdppc c.pprimeduc1564#cL.lnshpop1564 c.pprimeduc1564#cL.lnrgdppc if oecd == 0, a(id year) cl(id)
margins, dydx(pprimeduc1564) at(L.lnshpop1564 = (-.89(.1)-.09)) post
eststo educ3

* Plot coefficients
#delimit;
coefplot (educ1, msym(c)) (educ2, msym(s)) (educ3, msym(d)),
	at ciopts(recast(rspike))
	ytitle("Marginal effect of post-primary education on growth", size(medsmall))
	ylab(-2(1)3, nogrid angle(0) labsize(medsmall) format(%4.0f))
	ysca(titlegap(2))
	yline(0, lcolor(ltbluishgray))
	xtitle("Lag working-age share in total population", size(medsmall))
	xlab(-.9(.1)-.1 -.9 "0.40" -.8 "0.45" -.7 "0.50" -.6 "0.55" -.5 "0.61" -.4 "0.67" -.3 "0.74" -.2 "0.82" -.1 "0.90", nogrid angle(0) labsize(medsmall))
	xsca(titlegap(2))
	legend(rows(1) cols(3) ring(0) position(10) label(2 "Full Sample") label(4 "OECD") label(6 "Non OECD"))
	graphregion(color(white)) bgcolor(white)
;
#delimit cr

	
********************************************************************************
* Figure 2: Heterogeneity Across Age Structure and Education Age Composition


* Figure 2a: Effect of Age Structure

* Compute marginal effect for age group 15-24
reghdfe growth D.lnrkpc D.lnshpop1524 D.lnshpop2539 D.lnshpop4054 D.lnshpop5564 c.pprimeduc1564##cL.lnshpop1524 c.pprimeduc1564##cL.lnshpop2539 c.pprimeduc1564##cL.lnshpop4054 ///
	c.pprimeduc1564##cL.lnshpop5564 c.pprimeduc1564##cL.lnrgdppc, a(id year) cl(id)
margins, dydx(L.lnshpop1524) at(pprimeduc1564 = (0.09(.1)0.89)) post
eststo age1

* Compute marginal effect for age group 25-39
reghdfe growth D.lnrkpc D.lnshpop1524 D.lnshpop2539 D.lnshpop4054 D.lnshpop5564 c.pprimeduc1564##cL.lnshpop1524 c.pprimeduc1564##cL.lnshpop2539 c.pprimeduc1564##cL.lnshpop4054 ///
	c.pprimeduc1564##cL.lnshpop5564 c.pprimeduc1564##cL.lnrgdppc, a(id year) cl(id)
margins, dydx(L.lnshpop2539) at(pprimeduc1564 = (0.1(.1)0.9)) post
eststo age2

* Compute marginal effect for age group 40-54
reghdfe growth D.lnrkpc D.lnshpop1524 D.lnshpop2539 D.lnshpop4054 D.lnshpop5564 c.pprimeduc1564##cL.lnshpop1524 c.pprimeduc1564##cL.lnshpop2539 c.pprimeduc1564##cL.lnshpop4054 ///
	c.pprimeduc1564##cL.lnshpop5564 c.pprimeduc1564##cL.lnrgdppc, a(id year) cl(id)
margins, dydx(L.lnshpop4054) at(pprimeduc1564 = (0.11(.1)0.91)) post
eststo age3

* Compute marginal effect for age group 55-64
reghdfe growth D.lnrkpc D.lnshpop1524 D.lnshpop2539 D.lnshpop4054 D.lnshpop5564 c.pprimeduc1564##cL.lnshpop1524 c.pprimeduc1564##cL.lnshpop2539 c.pprimeduc1564##cL.lnshpop4054 ///
	c.pprimeduc1564##cL.lnshpop5564 c.pprimeduc1564##cL.lnrgdppc, a(id year) cl(id)
margins, dydx(L.lnshpop5564) at(pprimeduc1564 = (0.12(.1)0.92)) post
eststo age4

* Plot coefficients
#delimit;
coefplot (age1, msym(c)) (age2, msym(s)) (age3, msym(d)) (age4, msym(x) msize(vlarge)),
	at ciopts(recast(rspike))
	ytitle("Marginal effect of lagged age share on growth", size(medsmall))
	ylab(-.5(.5)1 0 "0" 1 "1", nogrid angle(0) labsize(medsmall) format(%4.1f))
	ysca(titlegap(2))
	yline(0, lcolor(ltbluishgray))
	xtitle("Share with post-primary education in working-age population", size(medsmall))
	xlab(.1(.1).9, nogrid angle(0) labsize(medsmall) format(%4.1f))
	xsca(titlegap(2))
	legend(order(2 4 6 8) rows(3) cols(2) ring(0) position(10) label(2 "15-24") label(4 "25-39") label(6 "40-54") label(8 "55-64"))
	graphregion(color(white)) bgcolor(white)
;
#delimit cr


* Figure 2b: Effect of Education Age Composition (Relative to Age Group 40-54)

* Compute marginal effect for age group 15-24
qui reghdfe growth D.lnrkpc D.lnshpop1564 L.lnshpop1564 c.shwappprimeduc1524##cL.lnshpop1564 c.shwappprimeduc2539##cL.lnshpop1564 c.shwappprimeduc5564##cL.lnshpop1564 ///
	c.shwappprimeduc1524##cL.lnrgdppc c.shwappprimeduc2539##cL.lnrgdppc c.shwappprimeduc5564##cL.lnrgdppc, a(id year) cl(id)
margins, dydx(shwappprimeduc1524) at(L.lnshpop1564 = (-.91(.1)-.11)) post
est sto ageeduc1
	
* Compute marginal effect for age group 25-39
qui reghdfe growth D.lnrkpc D.lnshpop1564 L.lnshpop1564 c.shwappprimeduc1524##cL.lnshpop1564 c.shwappprimeduc2539##cL.lnshpop1564 c.shwappprimeduc5564##cL.lnshpop1564 ///
	c.shwappprimeduc1524##cL.lnrgdppc c.shwappprimeduc2539##cL.lnrgdppc c.shwappprimeduc5564##cL.lnrgdppc, a(id year) cl(id)
margins, dydx(shwappprimeduc2539) at(L.lnshpop1564 = (-.9(.1)-.1)) post
est sto ageeduc2

* Compute marginal effect for age group 55-64
qui reghdfe growth D.lnrkpc D.lnshpop1564 L.lnshpop1564 c.shwappprimeduc1524##cL.lnshpop1564 c.shwappprimeduc2539##cL.lnshpop1564 c.shwappprimeduc5564##cL.lnshpop1564 ///
	c.shwappprimeduc1524##cL.lnrgdppc c.shwappprimeduc2539##cL.lnrgdppc c.shwappprimeduc5564##cL.lnrgdppc, a(id year) cl(id)
margins, dydx(shwappprimeduc5564) at(L.lnshpop1564 = (-.89(.1)-.09)) post
est sto ageeduc3	
	
* Plot coefficients
#delimit;
coefplot (ageeduc3, msym(x) msize(vlarge) mcol(dkorange) ciopts(lcol(dkorange)))
	(ageeduc1, msym(c) mcol(navy) ciopts(lcol(navy)))
	(ageeduc2, msym(s) mcol(cranberry) ciopts(lcol(cranberry))),
	at ciopts(recast(rspike))
	ytitle("Marginal effect of a change in the age education share" "at the expense of the age group 40-54 ", size(medsmall))
	ylab(-8(2)6 0 "0", nogrid angle(0) labsize(medsmall) format(%4.0f))
	ysca(titlegap(2))
	yline(0, lcolor(ltbluishgray))
	xtitle("Lag working-age share in total population", size(medsmall))
	xlab(-.9(.1)-.1 -.9 "0.40" -.8 "0.45" -.7 "0.50" -.6 "0.55" -.5 "0.61" -.4 "0.67" -.3 "0.74" -.2 "0.82" -.1 "0.90", nogrid angle(0) labsize(medsmall))
	xsca(titlegap(2))
	graphregion(color(white)) bgcolor(white)
	legend(order(4 6 2) rows(1) cols(3) ring(0) position(2)	label(4 "15-24") label(6 "25-39") label(2 "55-64"))
;
#delimit cr


********************************************************************************
* Supplementary Material
********************************************************************************
* Figure S1: Robustness Figure 1: Population Share with Tertiary Education


* Figure S1a: Effect of Age Structure

* Compute marginal effect for full sample
qui reghdfe growth D.lnrkpc D.lnshpop1564 tereduc1564 L.lnshpop1564 L.lnrgdppc c.tereduc1564#cL.lnshpop1564 c.tereduc1564#cL.lnrgdppc, a(id year) cl(id)
margins, dydx(L.lnshpop1564) at(tereduc1564 = (.09(.1).59)) post
eststo wap1

* Compute marginal effect for OECD countries
qui reghdfe growth D.lnrkpc D.lnshpop1564 tereduc1564 L.lnshpop1564 L.lnrgdppc c.tereduc1564#cL.lnshpop1564 c.tereduc1564#cL.lnrgdppc if oecd == 1, a(id year) cl(id)
margins, dydx(L.lnshpop1564) at(tereduc1564 = (.1(.1).6)) post
eststo wap2

* Compute marginal effect for non-OECD countries
qui reghdfe growth D.lnrkpc D.lnshpop1564 tereduc1564 L.lnshpop1564 L.lnrgdppc c.tereduc1564#cL.lnshpop1564 c.tereduc1564#cL.lnrgdppc if oecd == 0, a(id year) cl(id)
margins, dydx(L.lnshpop1564) at(tereduc1564 = (.11(.1).61)) post
eststo wap3
	
* Plot coefficients
#delimit;
coefplot (wap1, msym(c)) (wap2, msym(s)) (wap3, msym(d)),
	at ciopts(recast(rspike))
	ytitle("Marginal effect of lagged working-age share on growth", size(medsmall))
	ylab(-2(2)8, nogrid angle(0) labsize(medsmall) format(%4.0f))
	ysca(titlegap(2))
	yline(0, lcolor(ltbluishgray))
	xtitle("Share with tertiary education in working-age population", size(medsmall))
	xlab(.1(.1).6, nogrid angle(0) labsize(medsmall) format(%4.1f))
	xsca(titlegap(2))
	legend(rows(1) cols(3) ring(0) position(10) label(2 "Full Sample") label(4 "OECD") label(6 "Non OECD"))
	graphregion(color(white)) bgcolor(white)
;
#delimit cr


* Figure S1b: Effect of Education

* Compute marginal effect for full sample
qui reghdfe growth D.lnrkpc D.lnshpop1564 tereduc1564 L.lnshpop1564 L.lnrgdppc c.tereduc1564#cL.lnshpop1564 c.tereduc1564#cL.lnrgdppc, a(id year) cl(id)
margins, dydx(tereduc1564) at(L.lnshpop1564 = (-.91(.1)-.11)) post
eststo educ1

* Compute marginal effect for OECD countries
qui reghdfe growth D.lnrkpc D.lnshpop1564 tereduc1564 L.lnshpop1564 L.lnrgdppc c.tereduc1564#cL.lnshpop1564 c.tereduc1564#cL.lnrgdppc if oecd == 1, a(id year) cl(id)
margins, dydx(tereduc1564) at(L.lnshpop1564 = (-.9(.1)-.1)) post
eststo educ2

* Compute marginal effect for non-OECD countries
qui reghdfe growth D.lnrkpc D.lnshpop1564 tereduc1564 L.lnshpop1564 L.lnrgdppc c.tereduc1564#cL.lnshpop1564 c.tereduc1564#cL.lnrgdppc if oecd == 0, a(id year) cl(id)
margins, dydx(tereduc1564) at(L.lnshpop1564 = (-.89(.1)-.09)) post
eststo educ3

* Plot coefficients
#delimit;
coefplot (educ1, msym(c)) (educ2, msym(s)) (educ3, msym(d)),
	at ciopts(recast(rspike))
	ytitle("Marginal effect of tertiary education on growth", size(medsmall))
	ylab(-4(2)8, nogrid angle(0) labsize(medsmall) format(%4.0f))
	ysca(titlegap(2))
	yline(0, lcolor(ltbluishgray))
	xtitle("Lag working-age share in total population", size(medsmall))
	xlab(-.9(.1)-.1 -.9 "0.40" -.8 "0.45" -.7 "0.50" -.6 "0.55" -.5 "0.61" -.4 "0.67" -.3 "0.74" -.2 "0.82" -.1 "0.90", nogrid angle(0) labsize(medsmall))
	xsca(titlegap(2))
	legend(rows(1) cols(3) ring(0) position(10) label(2 "Full Sample") label(4 "OECD") label(6 "Non OECD"))
	graphregion(color(white)) bgcolor(white)
;
#delimit cr


********************************************************************************
* Figure S2: Robustness Figure 1: Average Years of Schooling


* Figure S2a: Effect of Age Structure

* Compute marginal effect for full sample
qui reghdfe growth D.lnrkpc D.lnshpop1564 yos1564 L.lnshpop1564 L.lnrgdppc c.yos1564#cL.lnshpop1564 c.yos1564#cL.lnrgdppc, a(id year) cl(id)
margins, dydx(L.lnshpop1564) at(yos1564 = (1.8(2)13.8)) post
eststo wap1

* Compute marginal effect for OECD countries
qui reghdfe growth D.lnrkpc D.lnshpop1564 yos1564 L.lnshpop1564 L.lnrgdppc c.yos1564#cL.lnshpop1564 c.yos1564#cL.lnrgdppc if oecd == 1, a(id year) cl(id)
margins, dydx(L.lnshpop1564) at(yos1564 = (2(2)14)) post
eststo wap2

* Compute marginal effect for non-OECD countries
qui reghdfe growth D.lnrkpc D.lnshpop1564 yos1564 L.lnshpop1564 L.lnrgdppc c.yos1564#cL.lnshpop1564 c.yos1564#cL.lnrgdppc if oecd == 0, a(id year) cl(id)
margins, dydx(L.lnshpop1564) at(yos1564 = (2.2(2)14.2)) post
eststo wap3
	
* Plot coefficients
#delimit;
coefplot (wap1, msym(c)) (wap2, msym(s)) (wap3, msym(d)),
	at ciopts(recast(rspike))
	ytitle("Marginal effect of lagged working-age share on growth", size(medsmall))
	ylab(-2(1)3, nogrid angle(0) labsize(medsmall) format(%4.0f))
	ysca(titlegap(2))
	yline(0, lcolor(ltbluishgray))
	xtitle("Average years of schooling in working-age population", size(medsmall))
	xlab(2(2)14, nogrid angle(0) labsize(medsmall) format(%4.0f))
	xsca(titlegap(2))
	legend(rows(1) cols(3) ring(0) position(10) label(2 "Full Sample") label(4 "OECD") label(6 "Non OECD"))
	graphregion(color(white)) bgcolor(white)
;
#delimit cr


* Figure S2b: Effect of Education

* Compute marginal effect for full sample
qui reghdfe growth D.lnrkpc D.lnshpop1564 yos1564 L.lnshpop1564 L.lnrgdppc c.yos1564#cL.lnshpop1564 c.yos1564#cL.lnrgdppc, a(id year) cl(id)
margins, dydx(yos1564) at(L.lnshpop1564 = (-.91(.1)-.11)) post
eststo educ1

* Compute marginal effect for OECD countries
qui reghdfe growth D.lnrkpc D.lnshpop1564 yos1564 L.lnshpop1564 L.lnrgdppc c.yos1564#cL.lnshpop1564 c.yos1564#cL.lnrgdppc if oecd == 1, a(id year) cl(id)
margins, dydx(yos1564) at(L.lnshpop1564 = (-.9(.1)-.1)) post
eststo educ2

* Compute marginal effect for non-OECD countries
qui reghdfe growth D.lnrkpc D.lnshpop1564 yos1564 L.lnshpop1564 L.lnrgdppc c.yos1564#cL.lnshpop1564 c.yos1564#cL.lnrgdppc if oecd == 0, a(id year) cl(id)
margins, dydx(yos1564) at(L.lnshpop1564 = (-.89(.1)-.09)) post
eststo educ3

* Plot coefficients
#delimit;
coefplot (educ1, msym(c)) (educ2, msym(s)) (educ3, msym(d)),
	at ciopts(recast(rspike))
	ytitle("Marginal effect of average years of schooling on growth", size(medsmall))
	ylab(-.2(.1).3 0 "0", nogrid angle(0) labsize(medsmall) format(%4.1f))
	ysca(titlegap(2))
	yline(0, lcolor(ltbluishgray))
	xtitle("Lag working-age share in total population", size(medsmall))
	xlab(-.9(.1)-.1 -.9 "0.40" -.8 "0.45" -.7 "0.50" -.6 "0.55" -.5 "0.61" -.4 "0.67" -.3 "0.74" -.2 "0.82" -.1 "0.90", nogrid angle(0) labsize(medsmall))
	xsca(titlegap(2))
	legend(rows(1) cols(3) ring(0) position(10) label(2 "Full Sample") label(4 "OECD") label(6 "Non OECD"))
	graphregion(color(white)) bgcolor(white)
;
#delimit cr

	
********************************************************************************
* Figure S3: Robustness Figure 1: Sample Restricted to Period 1980-2015


* Figure S3a: Effect of Age Structure

preserve
keep if year >= 1980

* Compute marginal effect for full sample
qui reghdfe growth D.lnrkpc D.lnshpop1564 pprimeduc1564 L.lnshpop1564 L.lnrgdppc c.pprimeduc1564#cL.lnshpop1564 c.pprimeduc1564#cL.lnrgdppc, a(id year) cl(id)
margins, dydx(L.lnshpop1564) at(pprimeduc1564 = (.09(.1).89)) post
eststo wap1

* Compute marginal effect for OECD countries
qui reghdfe growth D.lnrkpc D.lnshpop1564 pprimeduc1564 L.lnshpop1564 L.lnrgdppc c.pprimeduc1564#cL.lnshpop1564 c.pprimeduc1564#cL.lnrgdppc if oecd == 1, a(id year) cl(id)
margins, dydx(L.lnshpop1564) at(pprimeduc1564 = (.1(.1).9)) post
eststo wap2

* Compute marginal effect for non-OECD countries
qui reghdfe growth D.lnrkpc D.lnshpop1564 pprimeduc1564 L.lnshpop1564 L.lnrgdppc c.pprimeduc1564#cL.lnshpop1564 c.pprimeduc1564#cL.lnrgdppc if oecd == 0, a(id year) cl(id)
margins, dydx(L.lnshpop1564) at(pprimeduc1564 = (.11(.1).91)) post
eststo wap3
	
* Plot coefficients
#delimit;
coefplot (wap1, msym(c)) (wap2, msym(s)) (wap3, msym(d)),
	at ciopts(recast(rspike))
	ytitle("Marginal effect of lagged working-age share on growth", size(medsmall))
	ylab(-4(1)3, nogrid angle(0) labsize(medsmall) format(%4.0f))
	ysca(titlegap(2))
	yline(0, lcolor(ltbluishgray))
	xtitle("Share with post-primary education in working-age population", size(medsmall))
	xlab(.1(.1).9, nogrid angle(0) labsize(medsmall) format(%4.1f))
	xsca(titlegap(2))
	legend(rows(1) cols(3) ring(0) position(10) label(2 "Full Sample") label(4 "OECD") label(6 "Non OECD"))
	graphregion(color(white)) bgcolor(white)
;
#delimit cr

restore


* Figure S3b: Effect of Education

preserve
keep if year >= 1980

* Compute marginal effect for full sample
qui reghdfe growth D.lnrkpc D.lnshpop1564 pprimeduc1564 L.lnshpop1564 L.lnrgdppc c.pprimeduc1564#cL.lnshpop1564 c.pprimeduc1564#cL.lnrgdppc, a(id year) cl(id)
margins, dydx(pprimeduc1564) at(L.lnshpop1564 = (-.91(.1)-.11)) post
eststo educ1

* Compute marginal effect for OECD countries
qui reghdfe growth D.lnrkpc D.lnshpop1564 pprimeduc1564 L.lnshpop1564 L.lnrgdppc c.pprimeduc1564#cL.lnshpop1564 c.pprimeduc1564#cL.lnrgdppc if oecd == 1, a(id year) cl(id)
margins, dydx(pprimeduc1564) at(L.lnshpop1564 = (-.9(.1)-.1)) post
eststo educ2

* Compute marginal effect for non-OECD countries
qui reghdfe growth D.lnrkpc D.lnshpop1564 pprimeduc1564 L.lnshpop1564 L.lnrgdppc c.pprimeduc1564#cL.lnshpop1564 c.pprimeduc1564#cL.lnrgdppc if oecd == 0, a(id year) cl(id)
margins, dydx(pprimeduc1564) at(L.lnshpop1564 = (-.89(.1)-.09)) post
eststo educ3

* Plot coefficients
#delimit;
coefplot (educ1, msym(c)) (educ2, msym(s)) (educ3, msym(d)),
	at ciopts(recast(rspike))
	ytitle("Marginal effect of post-primary education on growth", size(medsmall))
	ylab(-4(1)3, nogrid angle(0) labsize(medsmall) format(%4.0f))
	ysca(titlegap(2))
	yline(0, lcolor(ltbluishgray))
	xtitle("Lag working-age share in total population", size(medsmall))
	xlab(-.9(.1)-.1 -.9 "0.40" -.8 "0.45" -.7 "0.50" -.6 "0.55" -.5 "0.61" -.4 "0.67" -.3 "0.74" -.2 "0.82" -.1 "0.90", nogrid angle(0) labsize(medsmall))
	xsca(titlegap(2))
	legend(rows(1) cols(3) ring(0) position(10) label(2 "Full Sample") label(4 "OECD") label(6 "Non OECD"))
	graphregion(color(white)) bgcolor(white)
;
#delimit cr

restore


********************************************************************************
* Figure S4: Robustness Figure 1: Extended Specifications (Additional Controls)


* Figure S4a: Effect of Age Structure

* Compute marginal effect for full sample
qui reghdfe growth D.lnrkpc D.lnshpop1564 pprimeduc1564 L.lnshpop1564 L.lnrgdppc c.pprimeduc1564#cL.lnshpop1564 c.pprimeduc1564#cL.lnrgdppc pvindex econfreedom, a(id year) cl(id)
margins, dydx(L.lnshpop1564) at(pprimeduc1564 = (.09(.1).89)) post
eststo wap1

* Compute marginal effect for OECD countries
qui reghdfe growth D.lnrkpc D.lnshpop1564 pprimeduc1564 L.lnshpop1564 L.lnrgdppc c.pprimeduc1564#cL.lnshpop1564 c.pprimeduc1564#cL.lnrgdppc pvindex econfreedom if oecd == 1, a(id year) cl(id)
margins, dydx(L.lnshpop1564) at(pprimeduc1564 = (.1(.1).9)) post
eststo wap2

* Compute marginal effect for non-OECD countries
qui reghdfe growth D.lnrkpc D.lnshpop1564 pprimeduc1564 L.lnshpop1564 L.lnrgdppc c.pprimeduc1564#cL.lnshpop1564 c.pprimeduc1564#cL.lnrgdppc pvindex econfreedom if oecd == 0, a(id year) cl(id)
margins, dydx(L.lnshpop1564) at(pprimeduc1564 = (.11(.1).91)) post
eststo wap3
	
* Plot coefficients
#delimit;
coefplot (wap1, msym(c)) (wap2, msym(s)) (wap3, msym(d)),
	at ciopts(recast(rspike))
	ytitle("Marginal effect of lagged working-age share on growth", size(medsmall))
	ylab(-2(1)3, nogrid angle(0) labsize(medsmall) format(%4.0f))
	ysca(titlegap(2))
	yline(0, lcolor(ltbluishgray))
	xtitle("Share with post-primary education in working-age population", size(medsmall))
	xlab(.1(.1).9, nogrid angle(0) labsize(medsmall) format(%4.1f))
	xsca(titlegap(2))
	legend(rows(1) cols(3) ring(0) position(10) label(2 "Full Sample") label(4 "OECD") label(6 "Non OECD"))
	graphregion(color(white)) bgcolor(white)
;
#delimit cr


* Figure S4b: Effect of Education

* Compute marginal effect for full sample
qui reghdfe growth D.lnrkpc D.lnshpop1564 pprimeduc1564 L.lnshpop1564 L.lnrgdppc c.pprimeduc1564#cL.lnshpop1564 c.pprimeduc1564#cL.lnrgdppc pvindex econfreedom, a(id year) cl(id)
margins, dydx(pprimeduc1564) at(L.lnshpop1564 = (-.91(.1)-.11)) post
eststo educ1

* Compute marginal effect for OECD countries
qui reghdfe growth D.lnrkpc D.lnshpop1564 pprimeduc1564 L.lnshpop1564 L.lnrgdppc c.pprimeduc1564#cL.lnshpop1564 c.pprimeduc1564#cL.lnrgdppc pvindex econfreedom if oecd == 1, a(id year) cl(id)
margins, dydx(pprimeduc1564) at(L.lnshpop1564 = (-.9(.1)-.1)) post
eststo educ2

* Compute marginal effect for non-OECD countries
qui reghdfe growth D.lnrkpc D.lnshpop1564 pprimeduc1564 L.lnshpop1564 L.lnrgdppc c.pprimeduc1564#cL.lnshpop1564 c.pprimeduc1564#cL.lnrgdppc pvindex econfreedom if oecd == 0, a(id year) cl(id)
margins, dydx(pprimeduc1564) at(L.lnshpop1564 = (-.89(.1)-.09)) post
eststo educ3

* Plot coefficients
#delimit;
coefplot (educ1, msym(c)) (educ2, msym(s)) (educ3, msym(d)),
	at ciopts(recast(rspike))
	ytitle("Marginal effect of post-primary education on growth", size(medsmall))
	ylab(-2(1)3, nogrid angle(0) labsize(medsmall) format(%4.0f))
	ysca(titlegap(2))
	yline(0, lcolor(ltbluishgray))
	xtitle("Lag working-age share in total population", size(medsmall))
	xlab(-.9(.1)-.1 -.9 "0.40" -.8 "0.45" -.7 "0.50" -.6 "0.55" -.5 "0.61" -.4 "0.67" -.3 "0.74" -.2 "0.82" -.1 "0.90", nogrid angle(0) labsize(medsmall))
	xsca(titlegap(2))
	legend(rows(1) cols(3) ring(0) position(10) label(2 "Full Sample") label(4 "OECD") label(6 "Non OECD"))
	graphregion(color(white)) bgcolor(white)
;
#delimit cr


********************************************************************************
* Figure S5: Robustness Figure 2: Heterogeneity in OECD vs. Non-OECD Countries


* Figure S5a: 2(a) Heterogeneity Across Age Structure: OECD Countries

* Compute marginal effect for age group 15-24
reghdfe growth D.lnrkpc D.lnshpop1524 D.lnshpop2539 D.lnshpop4054 D.lnshpop5564 c.pprimeduc1564##cL.lnshpop1524 c.pprimeduc1564##cL.lnshpop2539 c.pprimeduc1564##cL.lnshpop4054 ///
	c.pprimeduc1564##cL.lnshpop5564 c.pprimeduc1564##cL.lnrgdppc if oecd == 1, a(id year) cl(id)
margins if oecd == 1, dydx(L.lnshpop1524) at(pprimeduc1564 = (0.09(.1)0.89)) post
eststo age1

* Compute marginal effect for age group 25-39
reghdfe growth D.lnrkpc D.lnshpop1524 D.lnshpop2539 D.lnshpop4054 D.lnshpop5564 c.pprimeduc1564##cL.lnshpop1524 c.pprimeduc1564##cL.lnshpop2539 c.pprimeduc1564##cL.lnshpop4054 ///
	c.pprimeduc1564##cL.lnshpop5564 c.pprimeduc1564##cL.lnrgdppc if oecd == 1, a(id year) cl(id)
margins if oecd == 1, dydx(L.lnshpop2539) at(pprimeduc1564 = (0.1(.1)0.9)) post
eststo age2

* Compute marginal effect for age group 40-54
reghdfe growth D.lnrkpc D.lnshpop1524 D.lnshpop2539 D.lnshpop4054 D.lnshpop5564 c.pprimeduc1564##cL.lnshpop1524 c.pprimeduc1564##cL.lnshpop2539 c.pprimeduc1564##cL.lnshpop4054 ///
	c.pprimeduc1564##cL.lnshpop5564 c.pprimeduc1564##cL.lnrgdppc if oecd == 1, a(id year) cl(id)
margins if oecd == 1, dydx(L.lnshpop4054) at(pprimeduc1564 = (0.11(.1)0.91)) post
eststo age3

* Compute marginal effect for age group 55-64
reghdfe growth D.lnrkpc D.lnshpop1524 D.lnshpop2539 D.lnshpop4054 D.lnshpop5564 c.pprimeduc1564##cL.lnshpop1524 c.pprimeduc1564##cL.lnshpop2539 c.pprimeduc1564##cL.lnshpop4054 ///
	c.pprimeduc1564##cL.lnshpop5564 c.pprimeduc1564##cL.lnrgdppc if oecd == 1, a(id year) cl(id)
margins if oecd == 1, dydx(L.lnshpop5564) at(pprimeduc1564 = (0.12(.1)0.92)) post
eststo age4

* Plot coefficients
#delimit;
coefplot (age1, msym(c)) (age2, msym(s)) (age3, msym(d)) (age4, msym(x) msize(vlarge)),
	at ciopts(recast(rspike))
	ytitle("Marginal effect of lagged age share on growth", size(medsmall))
	ylab(-.5(.5)1.5 0 "0" 1 "1", nogrid angle(0) labsize(medsmall) format(%4.1f))
	ysca(titlegap(2))
	yline(0, lcolor(ltbluishgray))
	xtitle("Share with post-primary education in working-age population", size(medsmall))
	xlab(.1(.1).9, nogrid angle(0) labsize(medsmall) format(%4.1f))
	xsca(titlegap(2))
	legend(order(2 4 6 8) rows(3) cols(2) ring(0) position(10) label(2 "15-24") label(4 "25-39") label(6 "40-54") label(8 "55-64"))
	graphregion(color(white)) bgcolor(white)
;
#delimit cr


* Figure S5b: 2(a) Heterogeneity Across Age Structure: Non-OECD Countries

* Compute marginal effect for age group 15-24
reghdfe growth D.lnrkpc D.lnshpop1524 D.lnshpop2539 D.lnshpop4054 D.lnshpop5564 c.pprimeduc1564##cL.lnshpop1524 c.pprimeduc1564##cL.lnshpop2539 c.pprimeduc1564##cL.lnshpop4054 ///
	c.pprimeduc1564##cL.lnshpop5564 c.pprimeduc1564##cL.lnrgdppc if oecd == 0, a(id year) cl(id)
margins if oecd == 0, dydx(L.lnshpop1524) at(pprimeduc1564 = (0.09(.1)0.89)) post
eststo age1

* Compute marginal effect for age group 25-39
reghdfe growth D.lnrkpc D.lnshpop1524 D.lnshpop2539 D.lnshpop4054 D.lnshpop5564 c.pprimeduc1564##cL.lnshpop1524 c.pprimeduc1564##cL.lnshpop2539 c.pprimeduc1564##cL.lnshpop4054 ///
	c.pprimeduc1564##cL.lnshpop5564 c.pprimeduc1564##cL.lnrgdppc if oecd == 0, a(id year) cl(id)
margins if oecd == 0, dydx(L.lnshpop2539) at(pprimeduc1564 = (0.1(.1)0.9)) post
eststo age2

* Compute marginal effect for age group 40-54
reghdfe growth D.lnrkpc D.lnshpop1524 D.lnshpop2539 D.lnshpop4054 D.lnshpop5564 c.pprimeduc1564##cL.lnshpop1524 c.pprimeduc1564##cL.lnshpop2539 c.pprimeduc1564##cL.lnshpop4054 ///
	c.pprimeduc1564##cL.lnshpop5564 c.pprimeduc1564##cL.lnrgdppc if oecd == 0, a(id year) cl(id)
margins if oecd == 0, dydx(L.lnshpop4054) at(pprimeduc1564 = (0.11(.1)0.91)) post
eststo age3

* Compute marginal effect for age group 55-64
reghdfe growth D.lnrkpc D.lnshpop1524 D.lnshpop2539 D.lnshpop4054 D.lnshpop5564 c.pprimeduc1564##cL.lnshpop1524 c.pprimeduc1564##cL.lnshpop2539 c.pprimeduc1564##cL.lnshpop4054 ///
	c.pprimeduc1564##cL.lnshpop5564 c.pprimeduc1564##cL.lnrgdppc if oecd == 0, a(id year) cl(id)
margins if oecd == 0, dydx(L.lnshpop5564) at(pprimeduc1564 = (0.12(.1)0.92)) post
eststo age4

* Plot coefficients
#delimit;
coefplot (age1, msym(c)) (age2, msym(s)) (age3, msym(d)) (age4, msym(x) msize(vlarge)),
	at ciopts(recast(rspike))
	ytitle("Marginal effect of lagged age share on growth", size(medsmall))
	ylab(-.5(.5)1.5 0 "0" 1 "1", nogrid angle(0) labsize(medsmall) format(%4.1f))
	ysca(titlegap(2))
	yline(0, lcolor(ltbluishgray))
	xtitle("Share with post-primary education in working-age population", size(medsmall))
	xlab(.1(.1).9, nogrid angle(0) labsize(medsmall) format(%4.1f))
	xsca(titlegap(2))
	legend(order(2 4 6 8) rows(3) cols(2) ring(0) position(10) label(2 "15-24") label(4 "25-39") label(6 "40-54") label(8 "55-64"))
	graphregion(color(white)) bgcolor(white)
;
#delimit cr


* Figure S5c: 2(b) Effect of Age Structure of Human Capital: OECD Countries

* Compute marginal effect for age group 15-24
qui reghdfe growth D.lnrkpc D.lnshpop1564 L.lnshpop1564 c.shwappprimeduc1524##cL.lnshpop1564 c.shwappprimeduc2539##cL.lnshpop1564 c.shwappprimeduc5564##cL.lnshpop1564 ///
	c.shwappprimeduc1524##cL.lnrgdppc c.shwappprimeduc2539##cL.lnrgdppc c.shwappprimeduc5564##cL.lnrgdppc if oecd == 1, a(id year) cl(id)
margins if oecd == 1, dydx(shwappprimeduc1524) at(L.lnshpop1564 = (-.91(.1)-.11)) post
est sto ageeduc1
	
* Compute marginal effect for age group 25-39
qui reghdfe growth D.lnrkpc D.lnshpop1564 L.lnshpop1564 c.shwappprimeduc1524##cL.lnshpop1564 c.shwappprimeduc2539##cL.lnshpop1564 c.shwappprimeduc5564##cL.lnshpop1564 ///
	c.shwappprimeduc1524##cL.lnrgdppc c.shwappprimeduc2539##cL.lnrgdppc c.shwappprimeduc5564##cL.lnrgdppc if oecd == 1, a(id year) cl(id)
margins if oecd == 1, dydx(shwappprimeduc2539) at(L.lnshpop1564 = (-.9(.1)-.1)) post
est sto ageeduc2

* Compute marginal effect for age group 55-64
qui reghdfe growth D.lnrkpc D.lnshpop1564 L.lnshpop1564 c.shwappprimeduc1524##cL.lnshpop1564 c.shwappprimeduc2539##cL.lnshpop1564 c.shwappprimeduc5564##cL.lnshpop1564 ///
	c.shwappprimeduc1524##cL.lnrgdppc c.shwappprimeduc2539##cL.lnrgdppc c.shwappprimeduc5564##cL.lnrgdppc if oecd == 1, a(id year) cl(id)
margins if oecd == 1, dydx(shwappprimeduc5564) at(L.lnshpop1564 = (-.89(.1)-.09)) post
est sto ageeduc3	
	
* Plot coefficients
#delimit;
coefplot (ageeduc3, msym(x) msize(vlarge) mcol(dkorange) ciopts(lcol(dkorange)))
	(ageeduc1, msym(c) mcol(navy) ciopts(lcol(navy)))
	(ageeduc2, msym(s) mcol(cranberry) ciopts(lcol(cranberry))),
	at ciopts(recast(rspike))
	ytitle("Marginal effect of a change in the age education share" "at the expense of the age group 40-54 ", size(medsmall))
	ylab(-8(2)6 0 "0", nogrid angle(0) labsize(medsmall) format(%4.0f))
	ysca(titlegap(2))
	yline(0, lcolor(ltbluishgray))
	xtitle("Lag working-age share in total population", size(medsmall))
	xlab(-.9(.1)-.1 -.9 "0.40" -.8 "0.45" -.7 "0.50" -.6 "0.55" -.5 "0.61" -.4 "0.67" -.3 "0.74" -.2 "0.82" -.1 "0.90", nogrid angle(0) labsize(medsmall))
	xsca(titlegap(2))
	graphregion(color(white)) bgcolor(white)
	legend(order(4 6 2) rows(1) cols(3) ring(0) position(2)	label(4 "15-24") label(6 "25-39") label(2 "55-64"))
;
#delimit cr


* Figure S5d: 2(b) Effect of Age Structure of Human Capital: Non-OECD Countries

* Compute marginal effect for age group 15-24
qui reghdfe growth D.lnrkpc D.lnshpop1564 L.lnshpop1564 c.shwappprimeduc1524##cL.lnshpop1564 c.shwappprimeduc2539##cL.lnshpop1564 c.shwappprimeduc5564##cL.lnshpop1564 ///
	c.shwappprimeduc1524##cL.lnrgdppc c.shwappprimeduc2539##cL.lnrgdppc c.shwappprimeduc5564##cL.lnrgdppc if oecd == 0, a(id year) cl(id)
margins if oecd == 0, dydx(shwappprimeduc1524) at(L.lnshpop1564 = (-.91(.1)-.11)) post
est sto ageeduc1
	
* Compute marginal effect for age group 25-39
qui reghdfe growth D.lnrkpc D.lnshpop1564 L.lnshpop1564 c.shwappprimeduc1524##cL.lnshpop1564 c.shwappprimeduc2539##cL.lnshpop1564 c.shwappprimeduc5564##cL.lnshpop1564 ///
	c.shwappprimeduc1524##cL.lnrgdppc c.shwappprimeduc2539##cL.lnrgdppc c.shwappprimeduc5564##cL.lnrgdppc if oecd == 0, a(id year) cl(id)
margins if oecd == 0, dydx(shwappprimeduc2539) at(L.lnshpop1564 = (-.9(.1)-.1)) post
est sto ageeduc2

* Compute marginal effect for age group 55-64
qui reghdfe growth D.lnrkpc D.lnshpop1564 L.lnshpop1564 c.shwappprimeduc1524##cL.lnshpop1564 c.shwappprimeduc2539##cL.lnshpop1564 c.shwappprimeduc5564##cL.lnshpop1564 ///
	c.shwappprimeduc1524##cL.lnrgdppc c.shwappprimeduc2539##cL.lnrgdppc c.shwappprimeduc5564##cL.lnrgdppc if oecd == 0, a(id year) cl(id)
margins if oecd == 0, dydx(shwappprimeduc5564) at(L.lnshpop1564 = (-.89(.1)-.09)) post
est sto ageeduc3	
	
* Plot coefficients
#delimit;
coefplot (ageeduc3, msym(x) msize(vlarge) mcol(dkorange) ciopts(lcol(dkorange)))
	(ageeduc1, msym(c) mcol(navy) ciopts(lcol(navy)))
	(ageeduc2, msym(s) mcol(cranberry) ciopts(lcol(cranberry))),
	at ciopts(recast(rspike))
	ytitle("Marginal effect of a change in the age education share" "at the expense of the age group 40-54 ", size(medsmall))
	ylab(-8(2)6 0 "0", nogrid angle(0) labsize(medsmall) format(%4.0f))
	ysca(titlegap(2))
	yline(0, lcolor(ltbluishgray))
	xtitle("Lag working-age share in total population", size(medsmall))
	xlab(-.9(.1)-.1 -.9 "0.40" -.8 "0.45" -.7 "0.50" -.6 "0.55" -.5 "0.61" -.4 "0.67" -.3 "0.74" -.2 "0.82" -.1 "0.90", nogrid angle(0) labsize(medsmall))
	xsca(titlegap(2))
	graphregion(color(white)) bgcolor(white)
	legend(order(4 6 2) rows(1) cols(3) ring(0) position(2)	label(4 "15-24") label(6 "25-39") label(2 "55-64"))
;
#delimit cr


********************************************************************************
********************************************************************************